<template>
	<view class="user-money" v-if="isLogin">
		<view class="money">
			<view class="top">
				<text>资产钱包</text>
				<text class="iconfont" 
				:class="isShow ? 'icon-show' : 'icon-hide'" @click="handleSwit()"></text>
			</view>
			<view class="money-content">
				<view class="content">
					<text v-if="isShow">{{(userInfo.currency).toFixed(4)}}</text>
					<text v-else>******</text>
					<text v-if="isShow">≈ ¥{{(userInfo.currency*0.5).toFixed(4)}}</text>
					<text v-else>******</text>
				</view>
				<view class="money-btn">
					<view class="btn-list" @click="goPage('/pages/users/withdrawal/withdrawal')">
						<text class="iconfont icon-tixian"></text>
						<text>提现</text>
					</view>
					<view class="btn-list" @click="goPage('/pages/users/transfer/transfer')">
						<text class="iconfont icon-zhuanzhang"></text>
						<text>转账</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState} from "vuex";
	export default{
		name:"UserMoney",
		props:{
			show:{
				type:Boolean,
				default:false
			}
		},
		data(){
			return{
				isShow:false
			}
		},
		methods:{
			handleSwit(){
				if(this.isShow)return this.isShow=false,uni.setStorageSync("isMoney",false);
				return this.isShow=true,uni.setStorageSync("isMoney",true);
			},
			goPage(url){
				if(!this.isLogin){
					uni.navigateTo({
						url:"/pages/entrance/login/login"
					})
					return;
				}
				uni.navigateTo({
					url:url
				})
			}
		},
		computed:{
			...mapState(["isLogin","userInfo"]),
		},
		watch:{
			show:{
				handler(newValue){
					this.isShow = newValue;
				},
				immediate:true
			}
		}
	}
</script>

<style scoped lang="less" src="./UserMoney.less"></style>
